<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>我的界面</title>
    <link th:href="@{/img/web_icon.png}" rel="icon" type="image/x-icon">
    <!-- 自定义字体 -->
    <link th:href="@{/vendor/fontawesome-free/css/all.min.css}" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">

    <!-- 表格界面的主要css -->
    <link th:href="@{/css/sb-admin-2.css}" rel="stylesheet">

    <!-- 表格bootstrap -->
    <link th:href="@{/vendor/datatables/dataTables.bootstrap4.min.css}" rel="stylesheet">


</head>

<body id="page-top">

    <!-- Page Wrapper -->
    <div id="wrapper">
        <!-- 侧边栏 -->
        <div id="profileSideBar"
             th:replace="/common/module.html::sideBar(active='myPassword')"></div>
        <!-- 侧边栏到此为止啦 -->



        <!-- Content Wrapper -->
        <div id="content-wrapper" class="d-flex flex-column">

            <!-- 除去侧边栏后剩余的主体部分 -->
            <div id="content">

<!--                更换成模块-->
                <!-- 顶部头条内容 -->
                <div th:replace="/common/module.html::navBar"></div>
                <!-- 顶栏到此为止 -->

                <!-- 主体部分 -->
                <div class="container-fluid">

                    <!-- 头部消息提示 -->
<!--                    <h1 class="h3 mb-2 text-gray-800"></h1>-->

                    <!-- DataTales Example -->
                    <div class="card shadow mb-4">
                        <div class="card-header py-3">
                            <h6 class="m-0 font-weight-bold text-primary">我的基本信息</h6>
                        </div>
                        <div class="card-body col-6">
                            <div class="table-responsive">

                                <div class="card">
                                    <div class="card-body row">

                                        <div class="myInfo col-8">

                                            <form id="user_form" class="user p-2" action="/system/user/updatePassword" method="post">
                                                <div class="form-group col-10">
                                                    <input type="hidden" name="id" th:if="${user}" th:value="${user.id}">
                                                    <input type="hidden" name="dept" th:value="${user.dept.id}">
                                                    <div class="text-gray-800 mt-2 d-none">
                                                        <div class="text-gray-800"><span class="fa fa-user-circle mr-1"></span>我的用户名:</div>
                                                        <input type="text" class="form-control form-control-sm" name="username"
                                                               id="myName" th:value="${user.username}" disabled="disabled">
                                                    </div>
                                                    <div class="text-gray-800 mt-2 d-none">
                                                        <div class="text-gray-800"><span class="fa fa-envelope mr-1"></span>我的邮箱:</div>
                                                        <input type="email" class="form-control form-control-sm" name="email"
                                                               id="myEmail" th:value="${user.email}" disabled="disabled">
                                                    </div>
                                                    <div class="text-gray-800 mt-2 d-none">
                                                        <div class="text-gray-800"><span class="fa fa-pen mr-1"></span>我的笔名:</div>
                                                        <input type="text" class="form-control form-control-sm" name="nickname"
                                                               id="myNickname" th:value="${user.nickname}">
                                                    </div>
                                                    <div class="text-gray-800 mt-2">
                                                        <div class="text-gray-800"><span class="fa fa-key mr-1"></span>我的原密码:</div>
                                                        <input type="password" class="form-control form-control-sm" name="originPassword" id="originPassword">
                                                        <div class="badge badge-danger" th:if="${passwordMsg=='error'}">原密码输入错误！</div>
                                                    </div>
                                                    <div class="text-gray-800 mt-2">
                                                        <div class="text-gray-800"><span class="fa fa-key mr-1"></span>新密码:</div>
                                                        <input type="password" class="form-control form-control-sm" name="newPassword" id="newPassword">
                                                    </div>
                                                    <div class="text-gray-800 mt-2">
                                                        <div class="text-gray-800"><span class="fa fa-key mr-1"></span>重复密码:</div>
                                                        <input type="password" class="form-control form-control-sm" id="repeatPassword">
                                                    </div>
                                                    <div class="badge badge-success" th:if="${passwordMsg=='success'}">密码修改成功</div>
                                                </div>
                                            </form>

                                        </div>
                                    </div>
                                    <div class="card-footer">
                                        <button class="btn btn-outline-info" data-toggle="modal" data-target="#setPasswordInfo"
                                            onclick="checkPassword()">
                                            修改我的密码
                                        </button>
<!--                                        <button class="btn btn-outline-info" disabled="disabled">保存</button>-->
                                    </div>

                                </div>

                            </div>
                        </div>

                    </div>

                </div>
                <!-- /.container-fluid -->

            </div>
            <!-- 主体内容结束 -->

            <!-- 页脚 -->
            <footer class="sticky-footer bg-white">
                <div class="container my-auto">
                    <div class="copyright text-center my-auto">
                        <span>Copyright &copy; 三峡大学2021软件工程项目 Website 2021</span>
                    </div>
                </div>
            </footer>
            <!-- 页脚-->

        </div>
        <!-- 网页界面结束 -->

    </div>
    <!-- 主体可视界面结束，接下来时其他按钮或者弹窗 -->

    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
        <i class="fas fa-angle-up"></i>
    </a>

    <!-- 弹窗 -->
    <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
        aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">注意</h5>
                    <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                </div>
                <div class="modal-body">确定要退出登录吗?</div>
                <div class="modal-footer">
                    <button class="btn btn-secondary" type="button" data-dismiss="modal">取消</button>
                    <a class="btn btn-primary" href="/logout">确定</a>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="setPasswordInfo" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
         aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="setPasswordInfoModalLabel">修改密码提示</h5>
                    <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                </div>
                <div class="modal-body" id="passwordTips">是否确认修改密码?</div>
                <div class="modal-footer">
                    <button class="btn btn-secondary" type="button" data-dismiss="modal">取消</button>
                    <button class="btn btn-primary"  form="user_form" type="submit">确定</button>
                </div>
            </div>
        </div>
    </div>



    <!-- Bootstrap core JavaScript-->
    <script th:src="@{/vendor/jquery/jquery.min.js}"></script>
    <script th:src="@{/vendor/bootstrap/js/bootstrap.bundle.min.js}"></script>

    <!-- Core plugin JavaScript-->
    <script th:src="@{/vendor/jquery-easing/jquery.easing.min.js}"></script>

    <!-- Custom scripts for all pages-->
    <script th:src="@{/js/sb-admin-2.js}"></script>

    <!-- Page level plugins -->
    <script th:src="@{/vendor/datatables/jquery.dataTables.min.js}"></script>
    <script th:src="@{/vendor/datatables/dataTables.bootstrap4.min.js}"></script>

    <!-- Page level custom scripts -->
    <script th:src="@{/js/demo/datatables-demo.js}"></script>
    <script th:src="@{/js/getInformation.js}"></script>

    <script>
        // 在这里写更新密码的ajax
        let passwordTips = $('#passwordTips');//这里是修改密码的提示
        // 以下是举例
        function checkPassword(){
            let originPassword = $('#originPassword').val();
            let newPassword = $('#newPassword').val();
            let repeatPassword = $('#repeatPassword').val();
            if(originPassword==="" || newPassword==="" || repeatPassword===""){
                passwordTips.text("输入内容不能为空！");
            }
            else if(newPassword !== repeatPassword){
                passwordTips.text("两次输入的密码不相同！");
            }
            else{
                // xxxxxxxx
            }
        }
    </script>
</body>

</html>